// tabtenn.cpp -- simple base-class methods

#include "tabtenn.h"
#include <iostream>

int main() {
    using std::cout;
    using std::endl;
    TableTennisPlayer player1("Tara", "Boomdea", false);
    RatePlayer rPlayer1(1140, "Mallory", "Duck", true);
    rPlayer1.Name();    // derived object uses base method
    if (rPlayer1.HasTable())
        cout << ": has a table.\n";
    else
        cout << ": hasn't a table.\n";
    player1.Name(); // base object uses base method
    if (player1.HasTable())
        cout << ": has a table.\n";
    else
        cout << ": hasn't a table.\n";
    cout << "Name: ";
    rPlayer1.Name();
    cout << "; Rating: " << rPlayer1.Rating() << endl;
    // initialize RatedPlayer using TableTennisPlayer object
    RatePlayer rPlayer2(1212, player1);
    cout << "Name: ";
    rPlayer2.Name();
    cout << "; Rating: " << rPlayer2.Rating() << endl;
    return 0;
}

TableTennisPlayer::TableTennisPlayer(const string &fn, const string &ln, bool ht)
        : firstName(fn), lastName(ln), hasTable(ht) {}

void TableTennisPlayer::Name() const {
    std::cout << lastName << ", " << firstName;
}

// RatedPlayer methods
RatePlayer::RatePlayer(unsigned int r, const string &fn, const string &ln, bool ht) : TableTennisPlayer(fn, ln, ht) {
    rating = r;
}

RatePlayer::RatePlayer(unsigned int r, const TableTennisPlayer &tp) : TableTennisPlayer(tp), rating(r) {}
